/**
 * @file CLambdaTable.cpp Implementácia triedy CLambdaTable.
 *
 * @author Martin Kosorinský.
 * @date 1.4.2009.
 */

#include "CLambdaTable.hpp"

CLambdaTable::CLambdaTable() {
}

CLambdaTable::CLambdaTable(const CLambdaTable &tab) {
    CLambdaTable::const_iterator it;
    for (it = tab.begin(); it != tab.end(); it++) {
        this->add(it->first, it->second);
    }
}

CLambdaTable::~CLambdaTable() {
    this->clear();
}

CLambdaTable& CLambdaTable::operator=(const CLambdaTable & tab) {
    CLambdaTable::const_iterator it;
    this->clear();
    for (it = tab.begin(); it != tab.end(); it++) {
        this->add(it->first, it->second);
    }
    return *this;
};

void CLambdaTable::add(const epoint * P, const big distance) {
    epoint * p = epoint_init();
    epoint_copy((epoint*)P, p);
    big d = mirvar(0);
    copy((big)distance, d);
    table.insert(std::pair<epoint*, big>(p, d));
};

void CLambdaTable::clear() {
    iterator it;
    for (it = table.begin(); it != table.end(); it++) {
        mirkill(it->second);
        epoint_free(it->first);
    }
    table.clear();
}
